<template>
  <!-- 消防信息 -->
  <div>
    <public-modal
      width="900px"
      :footer="false"
      title="安全制度"
      modalStyle="detailModal"
      :publicVisible="publicVisible"
      cancelContext="拒绝"
      confirmContext="通过"
      @cancel="cancel"
    >
      <div slot="content">
        <!-- 安全制度 -->
        <div class="base-info-wrap">
          <div class="common-title">
            <div class="icon"></div>
            <div class="content">安全制度</div>
          </div>

          <div class="content-wrapper">
            <div class="flex">
              <div class="info-wrap f1">
                <div class="label common-lable">有无</div>
                <div class="value common-value">{{ securitySystemInfo.onSecuritySystem == 1 ? '有' : '无' }}</div>
              </div>

              <div class="info-wrap f1" v-if="securitySystemInfo.onSecuritySystem == 1">
                <div class="label common-lable">照片</div>
                <div class="value common-value click-color cursor" @click="werImg('securitySystemImgList')">查看</div>

                <ul id="securitySystemImgList" style="display: none">
                  <li v-for="(item, index) in securitySystemImgList" :key="index">
                    <img :src="imgPrefix + item" :data-original="imgPrefix + item" />
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div slot="footer"></div>
    </public-modal>
  </div>
</template>
<script>
import Viewer from 'viewerjs'
import 'viewerjs/dist/viewer.css'
import publicModal from '@/components/publicModal'
import { comMethods } from '@/mixins/comMethods'
import { getAction } from '@/api/manage'
export default {
  name: 'detailModal',
  components: { publicModal },
  mixins: [comMethods],
  data() {
    return {
      imgPrefix: '',
      publicVisible: false,

      bizId: '',
      companyId: '',
      securitySystemInfo: {},
      securitySystemImgList: [],
    }
  },

  methods: {
    show(records) {
      this.bizid = records.bizid
      this.companyId = records.companyId
      this.getPublicSecurityDetail()
      this.publicVisible = true
    },

    async getSCompanyPhoto() {
      let { result: securitySystemImgList } = await getAction('/sys/images_path/list', {
        bizId: this.bizid,
        bizType: 14,
      })
      securitySystemImgList.some((item) => {
        this.securitySystemImgList.push(item.path)
      })
    },

    async getPublicSecurityDetail() {
      let {
        result: { securitySystemInfo },
      } = await getAction('/industry/public_security/detail', { companyId: this.companyId })
      this.securitySystemInfo = securitySystemInfo
      console.log(securitySystemInfo, 'securitySystemInfo')

      this.getSCompanyPhoto()
    },

    cancel(target) {
      this.securitySystemImgList = []
      this.publicVisible = false
    },

    werImg(id) {
      const ViewerDom = document.getElementById(id)
      const viewer = new Viewer(ViewerDom, {
        toolbar: true,
        button: true,
        navbar: true,
        title: false,
        url: 'data-original',
        hide: function () {
          viewer.destroy()
        },
      })
      viewer.show()
    },
  },
}
</script>
<style scoped lang="less">
/deep/ .modalCotent {
  padding: 20px 40px;
  border-radius: 0 0 4px 4px;
}

img {
  display: none;
}

.content-wrapper {
  .common-lable {
    width: 120px;
  }
  .common-value {
    width: auto;
  }
}
</style>
